package com.hbusa.cotroller.chapter;

import com.hbusa.service.impl.*;
import com.hbusa.service.service.impl.ChapterServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author Sandwich
 * @version 1.0
 * @date 2021/12/27-20:53
 */

@WebServlet("/doChapterDelete")
public class chapterDeleteServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setCharacterEncoding("utf-8");
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;utf-8");

        String queryString = req.getQueryString();
        String[] split = queryString.split("=");

        int i = Integer.parseInt(split[1]);

        ChapterServiceImpl chapterService = new ChapterServiceImpl();
//        HttpSession session = req.getSession();


//        System.out.println(session.getAttribute("novelId"));

        //从session里面获取id
//        long novelId = (long)session.getAttribute("novelId");
        //System.out.println(novelId);
        chapterService.removeById(i);


        resp.sendRedirect("/doChapterFindAll");
    }
}
